 package com.honglu.backend.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.honglu.backend.bo.UUserBo;
import com.honglu.backend.common.shiroToken.TokenManager;
 
import com.honglu.backend.dao.StartGraphServiceDao;
 
import com.honglu.backend.entity.StartGraph;
 
import com.honglu.backend.service.StartGrapthService;
import com.honglu.backend.utils.DateUtils;
import com.honglu.utils.UUIDUtils;

@Service
public class StartGraphServiceImpl implements StartGrapthService {

	@Autowired
	private StartGraphServiceDao  startGraphServiceDao;

	@Override
	public List<StartGraph> getAll(StartGraph  tartGraph) {
		// TODO Auto-generated method stub
		tartGraph.setCurrentTime(DateUtils.getDate(new Date()));
		return startGraphServiceDao.getAll(tartGraph);
	}

	@Override
	public StartGraph selectByPrimaryKey(String graphId) {
		// TODO Auto-generated method stub
		return startGraphServiceDao.selectByPrimaryKey(graphId);
	}

	@Override
	public boolean deleteByPrimaryKey(String graphId) {
		// TODO Auto-generated method stub
		return startGraphServiceDao.deleteByPrimaryKey(graphId);
	}

	@Override
	public int insert(StartGraph startGraph) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	@Transactional
	public boolean insertSelective(StartGraph startGraph) {
		startGraph.setGraphId(UUIDUtils.getUUID());
		startGraph.setState(1);
		startGraph.setModifyTime(DateUtils.getDate(new Date()));
		startGraph.setCreateTime(DateUtils.getDate(new Date()));
		UUserBo user = TokenManager.getUser();
		if (user != null) {
			startGraph.setCreateMan(user.getUserName());
		} else {
			startGraph.setCreateMan("");
		}
		
		if (user != null) {
			startGraph.setModifyMan(user.getUserName());
		} else {
			startGraph.setModifyMan("");
		}
		return startGraphServiceDao.insertSelective(startGraph);
	}

	@Override
	public boolean updateByPrimaryKeySelective(StartGraph startGraph) {
		// TODO Auto-generated method stub
		return startGraphServiceDao.updateByPrimaryKeySelective(startGraph);
	}

	@Override
	public int updateByPrimaryKey(StartGraph startGraph) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int listAllCount(StartGraph startGraph) {
		// TODO Auto-generated method stub
		startGraph.setCurrentTime(DateUtils.getDate(new Date()));
		return startGraphServiceDao.listAllCount(startGraph);
	}
	 
	public List<StartGraph> findStartGraph(String date) {
		return startGraphServiceDao.findStartGraph(date);
	}
}
  